/*
 * @Description: 首页
 * @Author: iamsmiling
 * @Date: 2021-05-23 09:22:23
 * @LastEditTime: 2021-06-08 07:04:22
 */
import 'package:credit_business_circle/R/R.dart';
import 'package:credit_business_circle/components/filter_bar/filter_bar.dart';
import 'package:credit_business_circle/components/topic_card/topic_card.dart';
import 'package:credit_business_circle/domain/local/home/home_king_kong_entity.dart.dart';
import 'package:credit_business_circle/pages/home/home_controller.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';

import 'section/home_banner.dart';
import 'section/home_search_bar.dart';

class HomePage extends GetView<HomeController> {
  const HomePage({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return SafeArea(
      child: Container(
        padding: EdgeInsets.symmetric(horizontal: R.dimen.dp20),
        child: CustomScrollView(
          slivers: [
            SliverToBoxAdapter(
              child: HomeBanner(images: controller.images),
            ),

            ///金刚区
            SliverPadding(
              padding: EdgeInsets.symmetric(vertical: R.dimen.dp22),
              sliver: SliverGrid.count(
                crossAxisCount: 4,
                childAspectRatio: 1.2,
                children: [
                  for (HomeKingKongEntity item in controller.kongos)
                    Container(
                      child: Column(
                        crossAxisAlignment: CrossAxisAlignment.center,
                        children: [
                          Image.asset(item.icon),
                          Container(
                              margin: EdgeInsets.only(top: R.dimen.dp4),
                              child: Text(
                                item.label,
                                style: TextStyle(fontSize: R.dimen.sp13),
                              ))
                        ],
                      ),
                    )
                ],
              ),
            ),
            // SliverToBoxAdapter(
            //   child: HomeKingKong(kongos: controller.kongos),
            // ),
            SliverToBoxAdapter(
              child: HomeSearchBar(),
            ),

            SliverToBoxAdapter(
              child: Container(
                  margin: EdgeInsets.only(top: R.dimen.dp24),
                  child: FilterBar()),
            ),
            SliverList(
                delegate:
                    SliverChildBuilderDelegate((BuildContext context, int i) {
              return TopicCard(topic: controller.topics[i]);
            }, childCount: controller.topics.length))
          ],
        ),
      ),
    );
  }
}
